<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <script src="../js/vue.js"></script>
    <title>自定义标签</title>
</head>
<body>
<div id="root">
    <h2>文本高亮标红</h2>
    <p v-hightlight>你好</p>
    <h2>时间格式化</h2>
    <p v-date-format="nowTime"></p>
</div>

 <script>
let app = new Vue({
    el:'#root',
    data: {
      nowTime: new Date()
    },
    directives:{
        hightlight:{
            inserted(element){
              element.style="color: red;font-weight:bold"
            }
        },
        'date-format':{
            inserted(element,model){
                element.innerText = model.value.toLocaleString()
            }, 
            update(element,model) {
                element.innerText = model.value.toLocaleString()
            }
        }
    }
})
setInterval(() => {
    app.nowTime=new Date()
}, 1000)
 </script>   
</body>
</html>